

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>GPU (NVIDIA CUDA &amp; AMD ROCm) &mdash; Singularity container 3.5 documentation</title>
  

  
  
    <link rel="shortcut icon" href="_static/favicon.png"/>
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script src="_static/jquery.js"></script>
        <script src="_static/underscore.js"></script>
        <script src="_static/doctools.js"></script>
        <script src="_static/language_data.js"></script>
        <script src="_static/js/ga.js"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/custom.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="Contributing" href="contributing.html" />
    <link rel="prev" title="MPI应用" href="mpi.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> Singularity container
          

          
            
            <img src="_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          
            
            
              <div class="version">
                3.5
              </div>
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">介绍</a></li>
<li class="toctree-l1"><a class="reference internal" href="quick_start.html">快速入门</a></li>
<li class="toctree-l1"><a class="reference internal" href="security.html">Singularity安全</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build_a_container.html">Build容器</a></li>
<li class="toctree-l1"><a class="reference internal" href="definition_files.html">Definition文件</a></li>
<li class="toctree-l1"><a class="reference internal" href="build_env.html">Build环境</a></li>
<li class="toctree-l1"><a class="reference internal" href="singularity_and_docker.html">Singularity和Docker</a></li>
<li class="toctree-l1"><a class="reference internal" href="fakeroot.html">Fakeroot</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="signNverify.html">签名和认证</a></li>
<li class="toctree-l1"><a class="reference internal" href="key_commands.html">Key管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="encryption.html">容器加密</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="endpoint.html">容器仓库</a></li>
<li class="toctree-l1"><a class="reference internal" href="cloud_library.html">Cloud Library</a></li>
</ul>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="bind_paths_and_mounts.html">路径映射</a></li>
<li class="toctree-l1"><a class="reference internal" href="persistent_overlays.html">持久化Overlay</a></li>
<li class="toctree-l1"><a class="reference internal" href="running_services.html">运行服务</a></li>
<li class="toctree-l1"><a class="reference internal" href="environment_and_metadata.html">环境变量和元数据</a></li>
<li class="toctree-l1"><a class="reference internal" href="oci_runtime.html">OCI运行时</a></li>
<li class="toctree-l1"><a class="reference internal" href="plugins.html">插件</a></li>
<li class="toctree-l1"><a class="reference internal" href="security_options.html">安全选项</a></li>
<li class="toctree-l1"><a class="reference internal" href="networking.html">网络选项</a></li>
<li class="toctree-l1"><a class="reference internal" href="cgroups.html">Cgroups</a></li>
<li class="toctree-l1"><a class="reference internal" href="mpi.html">MPI应用</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">GPU支持</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#nvidia-gpus-cuda">NVIDIA GPUs &amp; CUDA</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id1">依赖条件</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#library">Library搜寻方式</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#tensorflow-gpu">例子 - tensorflow-gpu</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id2">多GPU支持</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id3">常见问题</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#cuda-error-unknown-when-everything-seems-to-be-correctly-configured">CUDA_ERROR_UNKNOWN when everything seems to be correctly configured</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#amd-gpus-rocm">AMD GPUs &amp; ROCm</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#id4">依赖条件</a></li>
<li class="toctree-l3"><a class="reference internal" href="#tensorflow-rocm">例子 - tensorflow-rocm</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#opencl">OpenCL应用</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#blender-opencl">例子 - Blender OpenCL</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="appendix.html">Appendix</a></li>
<li class="toctree-l1"><a class="reference internal" href="cli.html">Command Line Reference</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">Singularity container</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content style-external-links">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
      <li>GPU (NVIDIA CUDA &amp; AMD ROCm)</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            
              <a href="https://github.com/sylabs/singularity-userdocs/blob/master/gpu.rst" class="fa fa-github"> Edit on GitHub</a>
            
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="gpu-nvidia-cuda-amd-rocm">
<span id="gpu"></span><h1>GPU (NVIDIA CUDA &amp; AMD ROCm)<a class="headerlink" href="#gpu-nvidia-cuda-amd-rocm" title="Permalink to this headline">¶</a></h1>
<p>Singularity支持Nvidia的CUDA GPU计算框架和AMD的ROCm。这样在容器内就可以运行需要GPU的
机器学习框架，TensorFlow。只要在host上安装好了GPU的驱动。那在容器当中就可以使用，
Cuda和ROCE的,比如我们可以在RHEL 6的host上，运行最新的Ubuntu 18.04的TensorFlow容器。</p>
<p>通过其它的绑定选项，在容器中也可以使用OpenCL来使用GPU卡。</p>
<div class="section" id="nvidia-gpus-cuda">
<h2>NVIDIA GPUs &amp; CUDA<a class="headerlink" href="#nvidia-gpus-cuda" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">run</span></code>，<code class="docutils literal notranslate"><span class="pre">shell</span></code>, <code class="docutils literal notranslate"><span class="pre">exec</span></code> 等命令在执行的时候，通过 <code class="docutils literal notranslate"><span class="pre">--nv</span></code> 标记可以在容器中通过CUDA使用NVIDIA GPU运行程序。
<code class="docutils literal notranslate"><span class="pre">--nv</span></code> 标记:</p>
<ul class="simple">
<li><p>确保host上的GPU设备 <code class="docutils literal notranslate"><span class="pre">/dev/nvidiaX</span></code> 在容器内能被访问到。</p></li>
<li><p>如果容器中没有CUDA库，会将host上的CUDA库绑定到容器中，CUDA要和CPU的驱动能兼容。</p></li>
<li><p>将CUDA库加入 <code class="docutils literal notranslate"><span class="pre">LD_LIBRARY_PATH</span></code>。</p></li>
</ul>
<div class="section" id="id1">
<h3>依赖条件<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h3>
<p>要使用 <code class="docutils literal notranslate"><span class="pre">--nv</span></code> 标记在容器内运行CUDA程序，必须保证:</p>
<ul class="simple">
<li><p>Host上必须已经安装了GPU驱动，以及一个相应的NVIDIA/CUDA库。Host上不需要安装X server，除非你想在容器内给中运行图形应用。</p></li>
<li><p>需要在 <code class="docutils literal notranslate"><span class="pre">PATH</span></code> 下能找到 <code class="docutils literal notranslate"><span class="pre">nvidia-container-cli</span></code>，或者能在系统的库路径中找到NVIDIA的库。</p></li>
<li><p>容器中运行的程序在编译的时候使用的CUDA版本需要和映射进容器的CUDA兼容。</p></li>
</ul>
<p>这些条件通常在通过NVIDIA网站安装NVIDIA驱动和CUDA包后就能满足。Linux发行包中可能已经包含了NVIDIA驱动和CUDA包，
但是通常这些包都是过时的，在程序运行时可能会出问题。</p>
<div class="section" id="library">
<h4>Library搜寻方式<a class="headerlink" href="#library" title="Permalink to this headline">¶</a></h4>
<p>Singularity会使用 <code class="docutils literal notranslate"><span class="pre">nvidia-container-cli</span></code> 在host上搜寻NVIDIA/CUDA库并映射到容器，如果 <code class="docutils literal notranslate"><span class="pre">nvidia-container-cli</span></code> 不存在，
则会查找配置文件 <code class="docutils literal notranslate"><span class="pre">etc/singularity/nvliblist</span></code> 中列出的库，并将库映射到容器。</p>
<p>我们建议安装 <code class="docutils literal notranslate"><span class="pre">nvidia-container-cli</span></code> （<a class="reference external" href="https://nvidia.github.io/libnvidia-container/">NVIDIA libnvidia-container website</a>）</p>
<p>现在的 <code class="docutils literal notranslate"><span class="pre">etc/singularity/nvliblist</span></code> 中列出的库是基于host上的CUDA是10.1版本的情况，但是随着CUDA的升级，可能需要映射更多的库，或者移除某些不存在的库，
这时候就需要修改这个文件。 而 <code class="docutils literal notranslate"><span class="pre">nvidia-container-cli</span></code> 列出的库永远都是和host上的CUDA正确对应的。</p>
</div>
</div>
<div class="section" id="tensorflow-gpu">
<h3>例子 - tensorflow-gpu<a class="headerlink" href="#tensorflow-gpu" title="Permalink to this headline">¶</a></h3>
<p>TensorFlow是一个流程的机器学习的框架，但是在一些老的系统上安装比较困难，并且TensorFlow升级频繁。
而如果在容器中使用TensorFlow就不会安装的问题，并且更方便使用TensorFlow的不同版本。</p>
<p>TensorFlow在Docker Hub的镜像仓库中提供支持NVIDIA GPU的镜像 <a class="reference external" href="https://hub.docker.com/r/tensorflow/tensorflow/tags">tags page on Docker Hub</a></p>
<p>TensorFlow GPU镜像比较大，所以最好先将docker镜像转成SIF，然后再运行:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity pull docker://tensorflow/tensorflow:latest-gpu
...
INFO:    Creating SIF file...
INFO:    Build complete: tensorflow_latest-gpu.sif
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity run --nv tensorflow_latest-gpu.sif

________                               _______________
___  __/__________________________________  ____/__  /________      __
__  /  _  _ \_  __ \_  ___/  __ \_  ___/_  /_   __  /_  __ \_ | /| / /
_  /   /  __/  / / /(__  )/ /_/ /  /   _  __/   _  / / /_/ /_ |/ |/ /
/_/    \___//_/ /_//____/ \____//_/    /_/      /_/  \____/____/|__/


You are running this container as user with ID 1000 and group 1000,
which should map to the ID and group for your user on the Docker host. Great!

Singularity&gt;
</pre></div>
</div>
<p>在容器内，你可以使用tensorflow的 <code class="docutils literal notranslate"><span class="pre">list_local_devices()</span></code> 检查GPU是否已经可以使用:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Singularity&gt; python
Python 2.7.15+ (default, Jul  9 2019, 16:51:35)
[GCC 7.4.0] on linux2
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; from tensorflow.python.client import device_lib
&gt;&gt;&gt; print(device_lib.list_local_devices())
2019-11-14 15:32:09.743600: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-11-14 15:32:09.784482: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3292620000 Hz
2019-11-14 15:32:09.787911: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x565246634360 executing computations on platform Host. Devices:
2019-11-14 15:32:09.787939: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): Host, Default Version
2019-11-14 15:32:09.798428: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library libcuda.so.1
2019-11-14 15:32:09.842683: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1006] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-11-14 15:32:09.843252: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5652469263d0 executing computations on platform CUDA. Devices:
2019-11-14 15:32:09.843265: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): GeForce GT 730, Compute Capability 3.5
2019-11-14 15:32:09.843380: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:1006] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-11-14 15:32:09.843984: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties:
name: GeForce GT 730 major: 3 minor: 5 memoryClockRate(GHz): 0.9015
...
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3>多GPU支持<a class="headerlink" href="#id2" title="Permalink to this headline">¶</a></h3>
<p>默认情况下， Singularity保证所有的host设备在容器内都是可用的。
当使用 <code class="docutils literal notranslate"><span class="pre">--contain</span></code> 标记时，Singularity只会在容器内创建一个最小的的 <code class="docutils literal notranslate"><span class="pre">/dev</span></code> 树，
但是 <code class="docutils literal notranslate"><span class="pre">--nv</span></code> 标记会确保host上的所有NVIDIA GPU都能被映射到容器中。</p>
<p>这个和 <code class="docutils literal notranslate"><span class="pre">nvidia-docker</span></code> 对GPU的操作不太一样，nvidia-docker会根据环境变量 <code class="docutils literal notranslate"><span class="pre">NVIDIA_VISIBLE_DEVICES</span></code>
的设置来决定哪些GPU可以被映射到容器中。</p>
<p>使用 <code class="docutils literal notranslate"><span class="pre">--nv</span></code> 的时候通过设置 <code class="docutils literal notranslate"><span class="pre">SINGULARITYENV_CUDA_VISIBLE_DEVICES</span></code> 来决定在容器内CUDA程序能看到哪些GPU。</p>
<p>比如下面只使用host上的第一个GPU来运行tensorflow程序。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ SINGULARITYENV_CUDA_VISIBLE_DEVICES=0 singularity run --nv tensorflow_latest-gpu.sif

# or

$ export SINGULARITYENV_CUDA_VISIBLE_DEVICES=0
$ singularity run tensorflow_latest-gpu.sif
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h3>常见问题<a class="headerlink" href="#id3" title="Permalink to this headline">¶</a></h3>
<p>如果host上的NVIDIA驱动和CUDA库运行正常，通常在容器中也不会有问题，但是有时候也会看到如下的错误：</p>
<div class="section" id="cuda-error-unknown-when-everything-seems-to-be-correctly-configured">
<h4>CUDA_ERROR_UNKNOWN when everything seems to be correctly configured<a class="headerlink" href="#cuda-error-unknown-when-everything-seems-to-be-correctly-configured" title="Permalink to this headline">¶</a></h4>
<p>CUDA依赖于host上的多个kernel modules，在系统启动的时候，这些modules都没被加载。
其中一些modules在NVIDIA驱动栈初始化的时候会被加载，这个过程通过setuid root加载,
所以host上的任何用户都可以初始化驱动栈，但是在容器内部，setuid root不被允许，因此不能初始化驱动栈。</p>
<p>所以如果你碰到上面的错误，需要在host上初始化驱动栈。你可以使用 <code class="docutils literal notranslate"><span class="pre">modprobe</span> <span class="pre">nvidia_uvm</span></code> 命令加载module，
可以使用 <code class="docutils literal notranslate"><span class="pre">nvidia-persistenced</span></code> 防止modules没被加载。</p>
</div>
</div>
</div>
<div class="section" id="amd-gpus-rocm">
<h2>AMD GPUs &amp; ROCm<a class="headerlink" href="#amd-gpus-rocm" title="Permalink to this headline">¶</a></h2>
<p>Singularity从3.5开始通过 <code class="docutils literal notranslate"><span class="pre">--rocm</span></code> 标记支持AMD Radeon 来决定在容器内CUDA程序能看到哪些GPU。
在运行 <code class="docutils literal notranslate"><span class="pre">run</span></code>，<code class="docutils literal notranslate"><span class="pre">shell</span></code>, <code class="docutils literal notranslate"><span class="pre">exec</span></code> 等命令的时候，通过 <code class="docutils literal notranslate"><span class="pre">--rocm</span></code> 标记可以在容器中通过ROCm使用Radeon GPU运行程序。
使用 <code class="docutils literal notranslate"><span class="pre">--rocm</span></code> 标记:</p>
<ul class="simple">
<li><p>确保host上的GPU设备 <code class="docutils literal notranslate"><span class="pre">/dev/dri/</span></code> 在容器内能被访问到。</p></li>
<li><p>如果容器中没有ROCm库，会将host上的ROCm库绑定到容器中，ROCm要和CPU的驱动能兼容。</p></li>
<li><p>将ROCm库加入 <code class="docutils literal notranslate"><span class="pre">LD_LIBRARY_PATH</span></code>。</p></li>
</ul>
<div class="section" id="id4">
<h3>依赖条件<a class="headerlink" href="#id4" title="Permalink to this headline">¶</a></h3>
<p>要使用 <code class="docutils literal notranslate"><span class="pre">--rocm</span></code> 标记在容器内运行CUDA程序，必须保证:</p>
<ul class="simple">
<li><p>Host上必须已经安装了AMD GPU驱动，以及一个相应的ROCm库。Host上不需要安装X server，除非你想在容器内给中运行图形应用。</p></li>
<li><p>需要能在系统的库路径中找到ROCm的库。</p></li>
<li><p>容器中运行的程序在编译的时候使用的ROCm版本需要和映射进容器的ROcm兼容。</p></li>
</ul>
<p>这些条件通常按照 <a class="reference external" href="https://rocm.github.io/ROCmInstall.html">ROCm web site</a> 的指导都操作就可以满足。</p>
<p>Singularity在Debian 10上ROCm 2.8/2.9测试通过,在Ubuntu 18.04上ROCm 2.9测试通过。</p>
</div>
<div class="section" id="tensorflow-rocm">
<h3>例子 - tensorflow-rocm<a class="headerlink" href="#tensorflow-rocm" title="Permalink to this headline">¶</a></h3>
<p>TensorFlow是一个流程的机器学习的框架，但是在一些老的系统上安装比较困难，并且TensorFlow升级频繁。
而如果在容器中使用TensorFlow就不会安装的问题，并且更方便使用TensorFlow的不同版本。</p>
<p>TensorFlow在Docker Hub的镜像仓库中提供支持Radeon GPU的镜像 <a class="reference external" href="https://hub.docker.com/r/tensorflow/tensorflow/tags">tags page on Docker Hub</a></p>
<p>TensorFlow GPU镜像比较大，所以最好先将docker镜像转成SIF，然后再运行:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity pull docker://rocm/tensorflow:latest
...
INFO:    Creating SIF file...
INFO:    Build complete: tensorflow_latest.sif
</pre></div>
</div>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity run --rocm tensorflow_latest.sif
</pre></div>
</div>
<p>在容器内，你可以使用tensorflow的 <code class="docutils literal notranslate"><span class="pre">list_local_devices()</span></code> 检查GPU是否已经可以使用:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>Singularity&gt; ipython
Python 3.5.2 (default, Jul 10 2019, 11:58:48)
Type &#39;copyright&#39;, &#39;credits&#39; or &#39;license&#39; for more information
IPython 7.8.0 -- An enhanced Interactive Python. Type &#39;?&#39; for help.
&gt;&gt;&gt; from tensorflow.python.client import device_lib
...
&gt;&gt;&gt; print(device_lib.list_local_devices())
...
2019-11-14 16:33:42.750509: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1651] Found device 0 with properties:
name: Lexa PRO [Radeon RX 550/550X]
AMDGPU ISA: gfx803
memoryClockRate (GHz) 1.183
pciBusID 0000:09:00.0
...
</pre></div>
</div>
</div>
</div>
<div class="section" id="opencl">
<h2>OpenCL应用<a class="headerlink" href="#opencl" title="Permalink to this headline">¶</a></h2>
<p>使用 <code class="docutils literal notranslate"><span class="pre">--rocm</span></code> 和 <code class="docutils literal notranslate"><span class="pre">--nv</span></code> 标记都会自动映射一个各自实现的 OpenCL 的库到容器中。
但是 OpenCL 的应用不会直接使用映射到容器中的 OpenCL 的库，如果要使用映射到容器中的OpenCL的库，
还需要映射host上的 <code class="docutils literal notranslate"><span class="pre">/etc/OpenCL/vendors</span></code> 到容器中。</p>
<p>因此最简单的是使用 <code class="docutils literal notranslate"><span class="pre">--bind</span> <span class="pre">/etc/OpenCL</span></code> 将/etc/OpenCL映射进容器。</p>
<div class="section" id="blender-opencl">
<h3>例子 - Blender OpenCL<a class="headerlink" href="#blender-opencl" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="https://github.com/sylabs/examples">Sylabs examples repository</a> 有一个3D建模的例子’Blender’。</p>
<p>最新版本的Blender支持OpenCL渲染。Sylabs library提供了一个容器，可以使用OpenCL调用Radeon GPU来运行Blender图形应用。</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ singularity exec --rocm --bind /etc/OpenCL library://sylabs/examples/blender blender
</pre></div>
</div>
<p>注意，这里使用 <em>exec</em> 而没有使用 <em>run</em> 是因为容器中的 <em>runscript</em> 是批量的渲染(当然也可以用OpenCL)。</p>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="contributing.html" class="btn btn-neutral float-right" title="Contributing" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="mpi.html" class="btn btn-neutral float-left" title="MPI应用" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2017-2019, Sylabs Inc

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>